{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "解释 我不太理解，role = db.relationship('Role', backref='users')这个代码的意义，上面我理解相当于Python替我直接构造了一个Table的item"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class User(db.Model):\n",
    "    __tablename__ = 'users'\n",
    "    id = db.Column(db.Integer, primary_key=True)\n",
    "    name = db.Column(db.String(100), nullable=False)\n",
    "    contact = db.Column(db.String(20), nullable=False)\n",
    "    role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))\n",
    "    password = db.Column(db.String(255), nullable=False)\n",
    "    \n",
    "    role = db.relationship('Role', backref='users')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "很危险的删除Database的操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "db.drop_all() 是 SQLAlchemy 中的一个方法，用于删除数据库中所有的表及其数据。它通常在数据库的初始化过程中，或者在需要重置数据库时使用。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "science39",
   "language": "python",
   "name": "science39"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
